package com.coldchain.message.push;

import com.coldchain.common.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * TODO
 *
 * @ClassName PushAccountService
 * @Author fangliai
 * @Date 2018/9/21 0:18
 * @Vesion 1
 **/
@Service
public class PushAccountService {
   private static final String JIGUANG_PUSH_CACHE_KEY="jiguang_push_config";

   @Autowired
   private RedisUtils redisUtils;

   public JiguangPushAccount getPushAccount(){
       Object ob=redisUtils.getRBucket(JIGUANG_PUSH_CACHE_KEY).get();
       if(ob==null){
           return new JiguangPushAccount();
       }
       return (JiguangPushAccount) ob;
   }

   public void eidt(JiguangPushAccount account){
       redisUtils.getRBucket(JIGUANG_PUSH_CACHE_KEY).setAsync(account);
   }


   public static class JiguangPushAccount implements Serializable{

    private String appKey;
    private String appSecret;

       public String getAppKey() {
           return appKey;
       }

       public void setAppKey(String appKey) {
           this.appKey = appKey;
       }

       public String getAppSecret() {
           return appSecret;
       }

       public void setAppSecret(String appSecret) {
           this.appSecret = appSecret;
       }
   }

}
